package com.mytest.leetcode;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class Solution283 {

    public static void main(String[] args) {
        Solution283 solution189 = new Solution283();
        int [] nums = {0,1,0,3,12};
        solution189.moveZeroes(nums);
        log.info("{}", nums);
    }

    public void moveZeroes(int[] nums) {
        int n = nums.length, left = 0, right = 1;
        while (right < n) {
            if (nums[right] != 0) {
                reverse(nums, left, right);
                left++;
            }
            right++;
        }
    }

    public static void reverse(int[] nums, int left, int right){
        int temp = nums[left];
        nums[left] = nums[right];
        nums[right] = temp;
    }
}
